home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / optivc32 / vcestd.h < prev    next >
C/C++ Source or Header  |  1999-03-06  |  11KB  |  280 lines

  1. /*  VCEstd.h
  2.  
  3.   vector management functions:
  4.   complex manipulations on whole arrays or vectors of data type eComplex
  5.   (extended-precision complex)
  6.  
  7.   Copyright (c) 1996-1999 by Martin Sander
  8.   All Rights Reserved.
  9. */
  10.  
  11. #ifndef __VCESTD_H
  12. #define __VCESTD_H
  13. #if !defined( __VECLIB_H )
  14. #include <VecLib.h>
  15. #endif
  16.  
  17. #ifdef __BORLANDC__   /* 80-bit IEEE numbers supported.
  18.                          The following  130 lines apply 
  19.                          only to Borland C++            */
  20.  
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. /*************************  Generation  **************************/
  26.  
  27. ceVector   __vf  VCE_vector( ui size );
  28. ceVector   __vf  VCE_vector0( ui size );
  29.  
  30. /***************  Addressing single vector elements ******************/
  31.  
  32. eComplex _VFAR * VCE_Pelement( ceVector X, ui n );
  33.       /* returns a pointer to the n'th element of X. For the memory model
  34.          HUGE, the pointer is normalized. */
  35. #define VCE_element( X, n )  (*VCE_Pelement( X, n ))
  36.  
  37. /*******************  Initialization **********************************/
  38.  
  39. void  __vf  VCE_equ0( ceVector X, ui size );
  40. void  __vf  VCE_equ1( ceVector X, ui size );
  41. void  __vf  VCE_equC( ceVector X, ui size, eComplex C );
  42. void  __vf  VCE_equV( ceVector Y, ceVector X, ui size );
  43. void  __vf  VCEx_equV( ceVector Y, ceVector X, ui size,
  44.                        eComplex A, eComplex B );
  45. void  __vf  VCE_ramp( ceVector X, ui size, eComplex Start, eComplex Rise );
  46.  
  47. void  __vf  VE_CtoReIm( eVector Re, eVector Im, ceVector X, ui size );
  48. void  __vf  VE_ReImtoC( ceVector Y, eVector Re, eVector Im, ui size );
  49. void  __vf  VE_CtoRe( eVector Re, ceVector X, ui size );
  50. void  __vf  VE_RetoC( ceVector Y, eVector Re, ui size );
  51. void  __vf  VE_CtoIm( eVector Im, ceVector X, ui size );
  52. void  __vf  VE_ImtoC( ceVector Y, eVector Im, ui size );
  53. void  __vf  VE_CtoPolar( eVector Mag, eVector Arg, ceVector X, ui size );
  54. void  __vf  VE_PolartoC( ceVector Y, eVector Mag, eVector Arg, ui size );
  55. void  __vf  VE_CtoNorm( eVector Norm, ceVector X, ui size );
  56. void  __vf  VE_CtoAbs( eVector Abs, ceVector X, ui size );
  57. void  __vf  VE_CtoArg( eVector Arg, ceVector X, ui size );
  58. int   __vf  VCE_abs(  eVector Y, ceVector X, ui size );
  59.  
  60. #define     VCE_real         VE_CtoRe
  61. #define     VCE_imag         VE_CtoIm
  62. #define     VCE_arg          VE_CtoArg
  63. #define     VCE_norm         VE_CtoNorm
  64. #define     VCE_polar        VE_PolartoC
  65. #define     VCE_complex      VE_ReImtoC
  66.  
  67. /****************  Data-type interconversions  ***************************/
  68.  
  69. void  __vf   V_CFtoCE( ceVector Y, cfVector X, ui size );
  70. void  __vf   V_CEtoCF( cfVector Y, ceVector X, ui size );
  71. void  __vf   V_CDtoCE( ceVector Y, cdVector X, ui size );
  72. void  __vf   V_CEtoCD( cdVector Y, ceVector X, ui size );
  73.  
  74.  
  75. /****************  Index-oriented manipulations ***********************/
  76.  
  77. void  __vf  VCE_reflect( ceVector X, ui size );
  78. void  __vf  VCE_delete( ceVector X, ui size, ui pos );
  79. void  __vf  VCE_insert( ceVector X, ui size, ui pos, eComplex C );
  80. void  __vf  VCE_rev( ceVector Y, ceVector X, ui size );
  81. #ifdef V_HUGE
  82.    void  __vf  VCE_rotate( ceVector Y, ceVector X, ui size, long pos );
  83. #else
  84.    void  __vf  VCE_rotate( ceVector Y, ceVector X, ui size, int pos );
  85. #endif
  86.  
  87. void  __vf  VCE_indpick( ceVector Y, uiVector Ind, ui sizey, ceVector X );
  88. void  __vf  VCE_indput(  ceVector Y, ceVector X, uiVector Ind, ui sizex );
  89. void  __vf  VCE_subvector( ceVector Y, ui sizey, ceVector X, int step );
  90.  
  91.  
  92. /***************** Functions of a sub-set of elements  ********************/
  93.  
  94. void  __vf  VCE_subvector_equC(  ceVector Y, ui subsiz, unsigned samp,
  95.                                  eComplex C );
  96. void  __vf  VCE_subvector_equV(  ceVector Y, ui subsiz, unsigned samp,
  97.                                  ceVector X );
  98.     /*   for arithmetic functions of subsets, see <VCEmath.h>  */
  99.  
  100.  
  101. /**************** One-Dimensional Vector Operations ***********************/
  102.  
  103. extended  __vf  VCE_absmax(  ceVector X, ui size );
  104. extended  __vf  VCE_absmin(  ceVector X, ui size );
  105. extended  __vf  VCE_absmaxind( ui _VFAR *pos, ceVector X, ui size );
  106. extended  __vf  VCE_absminind( ui _VFAR *pos, ceVector X, ui size );
  107. #if defined __cplusplus && defined _CMATH_CLASSDEFS
  108. } // the following functions cannot be extern "C", if eComplex is a class
  109. #endif
  110. eComplex  __vf  VCE_maxReIm(     ceVector X, ui size );
  111. eComplex  __vf  VCE_minReIm(     ceVector X, ui size );
  112. eComplex  __vf  VCE_absmaxReIm(  ceVector X, ui size );
  113. eComplex  __vf  VCE_absminReIm(  ceVector X, ui size );
  114. eComplex  __vf  VCE_sum(     ceVector X, ui size );
  115. eComplex  __vf  VCE_prod(    ceVector X, ui size );
  116. eComplex  __vf  VCE_mean(   ceVector X, ui size );
  117. eComplex  __vf  VCE_meanwW( ceVector X, eVector Wt, ui size );
  118. #if defined __cplusplus && defined _CMATH_CLASSDEFS
  119. extern "C" {
  120. #endif
  121. void      __vf  VCE_runsum(  ceVector Y, ceVector X, ui size );
  122. void      __vf  VCE_runprod( ceVector Y, ceVector X, ui size );
  123. int       __vf  VCE_iselementC( ceVector Tab, ui size, eComplex C );
  124. ui        __vf  VCE_iselementV( ceVector Y, ceVector X, ui sizex,
  125.                                 ceVector Tab, ui sizetab );
  126.  
  127.  
  128. /*********  Fourier Transforms, Convolutions, Filtering  ****************/
  129.  
  130. void  __vf   VCEl_FFT( ceVector Y, ceVector X, ui size, int dir );
  131. void  __vf   VCEl_filter( ceVector Y, ceVector X, ceVector Flt, ui size );
  132.  
  133. void  __vf   VCEs_FFT( ceVector Y, ceVector X, ui size, int dir );
  134. void  __vf   VCEs_filter( ceVector Y, ceVector X, ceVector Flt, ui size );
  135.  
  136. #if( defined( __LARGE__ ) || defined( __COMPACT__ ) )
  137.    #define VCE_FFT       VCEl_FFT
  138.    #define VCE_filter    VCEl_filter
  139. #else
  140.    #define VCE_FFT       VCEs_FFT
  141.    #define VCE_filter    VCEs_filter
  142. #endif
  143.  
  144.  
  145. /***************************  Input and Output *****************************/
  146.  
  147. void  __vf  VCE_fprint( FILE _VFAR *stream, ceVector X, ui size,
  148.                                  unsigned nperline, unsigned linewidth );
  149. #if !defined _Windows || defined __FLAT__ || defined _WIN32
  150.     void  __vf  VCE_cprint( ceVector X, ui size, unsigned nperline );
  151. #endif
  152. #define     VCE_print( X, sz, npl ) VCE_fprint( stdout, X, sz, npl, 80 )\
  153.   /*  VCE_print, VCE_cprint usable only for DOS and Win32 console applications! */
  154. void  __vf  VCE_write( FILE _VFAR *stream, ceVector X, ui size );
  155. void  __vf  VCE_read( ceVector X, ui size, FILE _VFAR *stream );
  156. void  __vf  VCE_nwrite( FILE _VFAR *stream, unsigned n, ui size, ... );
  157. void  __vf  VCE_nread( unsigned n, ui size, FILE _VFAR *stream, ... );
  158. void  __vf  VCE_setWriteFormat( char _VFAR *FormatString );
  159.                                             /* for VCE_write and VCE_nwrite */
  160. void  __vf  VCE_setWriteSeparate( char _VFAR *SepString ); /* for VCE_write */
  161. void  __vf  VCE_setNWriteSeparate( char _VFAR *SepString ); /* for VCE_nwrite */
  162. #ifdef V_HUGE
  163.     void  __vf  VCE_store( FILE _VFAR *stream, ceVector X, ui size );
  164.     void  __vf  VCE_recall( ceVector X, ui size, FILE _VFAR *stream  );
  165. #else
  166.     #ifdef __cplusplus
  167.          void  inline VCE_store( FILE _VFAR *stream, ceVector X, ui size )
  168.          {    fwrite( X, sizeof(eComplex), size, stream ); 
  169.          }
  170.          void  inline VCE_recall( ceVector X, ui size, FILE _VFAR *stream )
  171.          {    fread(  X, sizeof(eComplex), size, stream );
  172.          }
  173.     #else
  174.         #define VCE_store( str, X, sz )  \
  175.                      fwrite( X, sizeof(eComplex), sz, str )
  176.         #define VCE_recall( X, sz, str ) \
  177.                      fread(  X, sizeof(eComplex), sz, str )
  178.     #endif
  179. #endif      /* VCE_store, VCE_recall in binary format */
  180.  
  181. #ifdef __cplusplus
  182. }    /* end of extern "C"  */
  183. #endif
  184.  
  185. #else   /* the following 130 lines apply only to compilers without
  186.            support for 80-bit IEEE numbers.  */
  187.  
  188. #define VCE_vector     VCD_vector
  189. #define VCE_vector0    VCD_vector0
  190. #define VCE_Pelement   VCD_Pelement
  191. #define VCE_element( X, n )  (*VCE_Pelement( X, n ))
  192.  
  193. #define VCE_equ0        VCD_equ0
  194. #define VCE_equ1        VCD_equ1
  195. #define VCE_equC        VCD_equC
  196. #define VCE_equV        VCD_equV
  197. #defin